var serverDate = undefined;
var menuData = undefined;

$(document).ready(function() {
	showLoading();
	$('title', parent.document).html($('title').text());
	setBaseUrl();
	$("#day").val();
	setTime();
	setInterval(setTime, 1000);
	getMenuData();
	menuData = setInterval(getMenuData, 30000);
	setTimeout(hideLoading, 500);
})
function getMenuData() {
	$.ajax({
		type: 'post',
		url: "getMenuData",
		success: function(data) {
			if (data) {
				clearInterval(menuData);
				$("#userName").html(data.userName);
				serverDate = new Date(data.date).getTime();
			} else {
				$("#userName").html("未知");
			}
			setTimeout(hideLoading, 500);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			setTimeout(hideLoading, 500);
			$("#userName").html("未登录");
		},
		timeout: function(data){
			setTimeout(hideLoading, 500);
			$("#userName").html("未登录");
		}
	})
}
function setTime() {
	$("#time").html(formatTime(serverDate));
	if (serverDate) {
		serverDate = serverDate + 1000;
	}
}
function formatTime(time) {
	document.getElementById("time").value=timeStamp2String(time);
}
function calibration() {
	formatTime();
}
function sure() {
	
}
